package com.gidgabs.modules.api.service.journal;

import com.gidgabs.common.utils.Assist;
import com.gidgabs.common.utils.LangUtil;
import com.gidgabs.common.utils.ReturnJson;
import com.gidgabs.dto.TbUserDto;
import com.gidgabs.dto.TbUserJournalDto;
import com.gidgabs.modules.dao.TbUserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by tby on 2018/7/12.
 */
@Service
@Transactional
public class JournalRankingService {
    @Autowired private TbUserDao tbUserDao;

    /**
     * 用户排行榜
     * @param pageSize
     * @param pageNo
     * @return
     */
    public ReturnJson<TbUserDto> queryList(Integer pageSize, Integer pageNo) {
        List<TbUserDto> tbUserDtos= tbUserDao.journalRanking(LangUtil.firstLimit(pageSize,pageNo),pageSize);
        Assist assist=new Assist();
        assist.andEq("delete_type",0);
        long tbUserRowCount = tbUserDao.getTbUserRowCount(assist);
        return ReturnJson.success("查询成功",tbUserDtos, (int) tbUserRowCount);
    }
}
